<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */
use Hyperf\ConfigCenter\Mode;
use Hyperf\ConfigNacos\Constants;
use Hyperf\ConfigNacos\NacosDriver;

use function Hyperf\Support\env;

// Nacos 配置中心
return [
    'enable' => (bool) env('CONFIG_CENTER_ENABLE', true),
    'driver' => env('CONFIG_CENTER_DRIVER', 'nacos'),
    'mode' => env('CONFIG_CENTER_MODE', Mode::PROCESS),
    'drivers' => [
        'nacos' => [
            'driver' => NacosDriver::class,
            'merge_mode' => Constants::CONFIG_MERGE_OVERWRITE,
            'interval' => 3,
            'default_key' => 'nacos_config',
            'listener_config' => [
                'database' => [
                    'data_id' => 'database.json',
                    'group' => env('CONFIG_NACOS_GROUP', 'DEFAULT_GROUP'),
                    'tenant' => env('CONFIG_NACOS_TENANT', 'public'),
                    'type' => 'json'
                ],
                'redis' => [
                    'data_id' => 'redis.json',
                    'group' => env('CONFIG_NACOS_GROUP', 'DEFAULT_GROUP'),
                    'tenant' => env('CONFIG_NACOS_TENANT', 'public'),
                    'type' => 'json'
                ],
            ],
            'client' => [
                // nacos server url like https://nacos.hyperf.io, Priority is higher than host:port
                // 'uri' => '',
                'host' => env('CONFIG_NACOS_HOST', '127.0.0.1'),
                'port' => env('CONFIG_NACOS_PORT', 8848),
                'username' => env('CONFIG_NACOS_USERNAME', 'nacos'),
                'password' => env('CONFIG_NACOS_PASSWORD', 'nacos'),
                'guzzle' => [
                    'config' => null,
                ],
                // Only support for nacos v2.
                'grpc' => [
                    'enable' => false,
                    'heartbeat' => 10,
                ],
            ],
        ],
    ],
];
